package concert;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

// 切面
// 观看演出的观众
@Aspect
public class Audience {

    // 定义命名的切点
    @Pointcut("execution(* concert.Performance.perform(..))")
    public void performance(){}

    // 环绕通知
    @Around("performance()")
    public void watchPerformance(ProceedingJoinPoint joinPoint){
        try{
            System.out.println("静音");
            System.out.println("入座");
            joinPoint.proceed();
            System.out.println("鼓掌!");
        }catch (Throwable e){
            System.out.println("要求退钱");
        }
    }

    /*
    // 表演之前
    @Before("performance()")
    public void silenceCellPhones(){
        System.out.println("手机开启静音模式");
    }

    // 表演之前
    @Before("performance()")
    public void takeSeats(){
        System.out.println("就座");
    }

    // 表演之后
    @AfterReturning("performance()")
    public void applause(){
        System.out.println("鼓掌");
    }

    // 表演失败之后
    @AfterThrowing("performance()")
    public void demandRefund(){
        System.out.println("要求退款");
    }
    */
}
